app.controller('vipRedWithdrawPageCtrl', function(
    $scope,
    $state,
    $mydialog,
    $ionicPopup,
    $ionicModal,
    $stateParams,
    $http,
    $myconfig,
    $ionicConfig) {


        $scope.useMes = JSON.parse(localStorage.getItem('user'));
        // console.log($scope.useMes)
        // $scope.money = 0;

        //提现操作
    var isReq = false;
        $scope.haveMoney = function(){
            if(isReq){
                return
            }
            isReq = true;
            console.log(document.getElementById('money').value * 100);
            $http.post($myconfig.api.base_host + '/users/withdraw',{
                "user_id":$scope.useMes.id,
                "amount":document.getElementById('money').value * 100,
                version: '1.0.9'
            }).then(function(res){
                isReq = false;
                if(res.data.success){
                    // $scope.success_text = '提现成功,请注意查收';
                    // $mydialog.success($scope);
                    $http.get($myconfig.api.base_host + '/users/user_info?mobile=' + $scope.useMes.mobile)
                    .then(function(res){
                        if(res.data.success){
                            localStorage.setItem('user',JSON.stringify(res.data.data))
                        }
                    });
                    $state.go('app.vip_red_withdrawEnd',{mone:document.getElementById('money').value});
                }else{
                    $scope.err = res.data.data;
                    $mydialog.fail($scope);
                }
            });
        };

        var allMoney = $scope.useMes.bonusbalance / 100;
        //全部提现
        $scope.Allwith = function(){
            $scope.money = allMoney;
            document.getElementById('money').value=allMoney;
        };

    $scope.$on('$ionicView.enter', function(){

        $ionicConfig.views.swipeBackEnabled(false);

    });

});
